<template>
  <div
    class="main main_bg"
    :style="$store.state.isApp ? 'paddingTop:.2rem' : 'paddingTop:1.2rem'"
  >
    <gltitle
      :titleSize="titleSize"
      :is_mt="is_mt"
      v-if="!$store.state.isApp"
      @preserve="preserve"
    ></gltitle>
    <div class="container">
      <div class="head">
        <div class="cname db">
          <div class="flex">{{ $t("income.doc22") }}</div>
          <div class="str">
            <img
              :src="
                !isShowAsset
                  ? require('@/assets/images/y_off.png')
                  : require('@/assets/images/y_on.png')
              "
              alt=""
              @click="handleHideAsset()"
            />

            <!--<img src="../../assets/images/y_off.png" alt="">-->
          </div>
        </div>
        <div class="price">
          <var>≈</var>{{ isShowAsset ? yesterdayAmount : "******"
          }}
          <!-- <span>USDT</span> -->
        </div>

        <!--<ul v-if="is_a">-->
          <!--<li class="db">-->
            <!--<div class="name">{{ $t("income.doc23") }}</div>-->
            <!--<div class="flex tar">-->
              <!--≈{{ isShowAsset ? datainfo.staticAmount : "******" }} USDT-->
            <!--</div>-->
          <!--</li>-->
          <!--<li class="db">-->
            <!--<div class="name">{{ $t("income.doc24") }}</div>-->
            <!--<div class="flex tar">-->
              <!--≈{{ isShowAsset ? datainfo.dynamicAmount : "******" }} USDT-->
            <!--</div>-->
          <!--</li>-->
          <!--&lt;!&ndash;<li class="db">&ndash;&gt;-->
            <!--&lt;!&ndash;<div class="name">{{ $t("income.doc25") }}</div>&ndash;&gt;-->
            <!--&lt;!&ndash;<div class="flex tar">&ndash;&gt;-->
              <!--&lt;!&ndash;≈{{ isShowAsset ? datainfo.communityAmount : "******" }} USDT&ndash;&gt;-->
            <!--&lt;!&ndash;</div>&ndash;&gt;-->
          <!--&lt;!&ndash;</li>&ndash;&gt;-->
          <!--&lt;!&ndash;<li class="db">&ndash;&gt;-->
            <!--&lt;!&ndash;<div class="name">{{ $t("income.doc26") }}</div>&ndash;&gt;-->
            <!--&lt;!&ndash;<div class="flex tar">&ndash;&gt;-->
              <!--&lt;!&ndash;≈{{ isShowAsset ? datainfo.agentAmount : "******" }} USDT&ndash;&gt;-->
            <!--&lt;!&ndash;</div>&ndash;&gt;-->
          <!--&lt;!&ndash;</li>&ndash;&gt;-->
          <!--<li class="db">-->
            <!--<div class="name">{{ $t("income.doc27") }}</div>-->
            <!--<div class="flex tar">-->
              <!--≈{{ isShowAsset ? datainfo.recommendAmount : "******" }} USDT-->
            <!--</div>-->
          <!--</li>-->
        <!--</ul>-->

        <!--<div class="status tac" :class="is_a ? 'xc180' : ''" @click="status()">-->
          <!--<img src="../../assets/images/i_down2.png" alt="" />-->
        <!--</div>-->
      </div>

      <div class="box1">
        <!--<div class="cname">-->
          <!--<img src="../../assets/images/i_dj.png" alt="" />{{-->
            <!--$t("income.doc36")-->
          <!--}}：X {{ $store.state.userData.communityLevel }}-->
        <!--</div>-->
        <ul>
          <li
            class="db"
            v-for="(item, k) in lineData"
            :key="k"
            @click="link(item)"
          >
            <div class="flex">
              <h5>{{ item.name }}</h5>
              <span class="c-999">{{ item.dec }}</span>
            </div>
            <div class="str">
              {{ isShowAsset ? item.sun : "******" }} {{ item.dw }}
            </div>
          </li>
          <!--<li class="db">-->
          <!--<div class="flex">-->
          <!--<h5>团队管理</h5>-->
          <!--<span class="c-999">推荐社区团队人员列表</span>-->
          <!--</div>-->
          <!--<div class="str">-->
          <!--2222 人-->
          <!--</div>-->
          <!--</li>-->
          <!--<li class="db">-->
          <!--<div class="flex">-->
          <!--<h5>静态收益</h5>-->
          <!--<span class="c-999">矿机挖矿和理财收益</span>-->
          <!--</div>-->
          <!--<div class="str">-->
          <!--23878323 USDT-->
          <!--</div>-->
          <!--</li>-->
          <!--<li class="db">-->
          <!--<div class="flex">-->
          <!--<h5>动态收益</h5>-->
          <!--<span class="c-999">业务员推广APP抽成</span>-->
          <!--</div>-->
          <!--<div class="str">-->
          <!--23878323 USDT-->
          <!--</div>-->
          <!--</li>-->
          <!--<li class="db">-->
          <!--<div class="flex">-->
          <!--<h5>社区收益</h5>-->
          <!--<span class="c-999">团队社区和平级社区的分红</span>-->
          <!--</div>-->
          <!--<div class="str">-->
          <!--23878323 USDT-->
          <!--</div>-->
          <!--</li>-->
          <!--<li class="db">-->
          <!--<div class="flex">-->
          <!--<h5>推广矿机</h5>-->
          <!--<span class="c-999">业务员推广购买矿机抽成</span>-->
          <!--</div>-->
          <!--<div class="str">-->
          <!--23878323 USDT-->
          <!--</div>-->
          <!--</li>-->
          <!--<li class="db">-->
          <!--<div class="flex">-->
          <!--<h5>代理收益</h5>-->
          <!--<span class="c-999">相关地区销售矿机等分红</span>-->
          <!--</div>-->
          <!--<div class="str">-->
          <!--69874589 USDT-->
          <!--</div>-->
          <!--</li>-->
        </ul>
      </div>
    </div>

    <verifyPass
      :isShow_VerifyPssPopup="isShow_VerifyPssPopup"
      @hadleHideVerifyPssPopup="hadleHideVerifyPssPopup"
      @getPayPass="getPayPass"
    ></verifyPass>
  </div>
</template>
<script>
import { mapActions, mapMutations } from "vuex";
export default {
  data() {
    return {
      it: 0,
      if_check: false,
      titleSize: this.$t("title.income"),
      is_mt: true,
      titleRight: this.$tc("income.doc35", 1),
      is_a: false,
      datainfo: "",
      lineData: [
        {
          name: this.$tc("income.doc28", 1),
          dec: this.$tc("income.doc28", 2),
          dw: "USDT",
          sun: "0",
          id: "0",
        },
        {
          name: this.$tc("income.doc29", 0),
          dec: this.$tc("income.doc29", 1),
          dw: this.$tc("income.doc29", 2),
          sun: "0",
          id: "100",
        },
        {
          name: this.$tc("income.doc30", 1),
          dec: this.$tc("income.doc30", 2),
          dw: "USDT",
          sun: "0",
          id: "1",
        },
        // {
        //   name: this.$tc("income.doc31", 1),
        //   dec: this.$tc("income.doc31", 2),
        //   dw: "USDT",
        //   sun: "0",
        //   id: "2",
        // },
        // {
        //   name: this.$tc("income.doc32", 1),
        //   dec: this.$tc("income.doc32", 2),
        //   dw: "USDT",
        //   sun: "0",
        //   id: "3",
        // },
        {
          name: this.$tc("income.doc33", 1),
          dec: this.$tc("income.doc33", 2),
          dw: "USDT",
          sun: "0",
          id: "2",
        },
        {
          name: this.$tc("income.doc34", 1),
          dec: this.$tc("income.doc34", 2),
          dw: "USDT",
          sun: "0",
          id: "3",
        },
        {
          name: this.$tc("income.doc37", 1),
          dec: this.$tc("income.doc37", 2),
          dw: "USDT",
          sun: "0",
          id: "4",
        },
        {
          name: this.$t("doc.doc29"),
          dec: this.$t("doc.doc30"),
          dw: 'USDT',
          sun: "0",
          id: "5",
        },
        {
          name: this.$t("doc.doc18"),
          dec: this.$t("doc.doc19"),
          dw: this.$t("doc.doc26"),
          sun: "0",
          id: "5",
        },
        {
          name: this.$t("doc.doc20"),
          dec: this.$t("doc.doc21"),
          dw: this.$t("doc.doc26"),
          sun: "0",
          id: "5",
        },
        {
          name: this.$t("doc.doc22"),
          dec: this.$t("doc.doc23"),
          dw: 'USDT',
          sun: "0",
          id: "5",
        },
        {
          name: this.$t("doc.doc24"),
          dec: this.$t("doc.doc25"),
          dw: 'USDT',
          sun: "0",
          id: "5",
        },
      ],

      isShow_VerifyPssPopup: false,
      isShowAsset: false,
      yesterdayAmount:0
    };
  },

  created() {
    this.isShowAsset = this.$store.state.welfareShowEyes_2;
    if (this.isShowAsset) {
      this.getdata();
    }
    // 因为 1.暂时在app的 webview里面没办法知道是从3级页面回来的？还是刚进来的；2.ios 里面 wkwebview又没办法写session,所以做此判断
    if (window.history.length < 2) {
      this.isShowAsset = false;
      this.$store.dispatch("SetWelfareEyes_2", this.isShowAsset);
    }
  },
  mounted() {
    window["preserve"] = () => {
      this.preserve();
    };
  },
  methods: {
    getdata() {
      this.$post(this.URL.income.incomedata, {}).then((res) => {
        if (res.code == 0) {

          this.yesterdayAmount = res.data.yesterdayAmount;
          this.lineData[0].sun = res.data.teamAchievement;
          this.lineData[1].sun = res.data.teamCount;
          this.lineData[2].sun = res.data.staticAmount;
          this.lineData[3].sun = res.data.dynamicAmount;
          this.lineData[4].sun = res.data.communityAmount;
          this.lineData[5].sun = res.data.recommendAmount;
          this.lineData[6].sun = res.data.sumTradeAmount;
          this.lineData[7].sun = res.data.team7NewCount;
          this.lineData[8].sun = res.data.team7Count;
          this.lineData[9].sun = res.data.teamSumTradeAmount;
          this.lineData[10].sun = res.data.team7SumTradeAmount;
          // this.lineData[6].sun = res.data.agentAmount;
          console.log(this.lineData[4],'line')
        }
      });
      // this.$post(this.URL.income.yesterday, {}).then((res) => {
      //   if (res.code == 0) {
      //     this.datainfo = res.data;
      //   }
      // });
    },
    handleHideAsset() {
      // if(this.$store.state.isApp){
      //     this.isShowAsset = !this.isShowAsset;
      //     this.$store.dispatch('SetWelfareEyes_2', this.isShowAsset);
      //     return
      // }

      if (this.common.isVerify()) {
        this.isShowAsset = !this.isShowAsset;
        this.getdata();
        this.$store.dispatch("SetWelfareEyes_2", this.isShowAsset);
        return;
      }

      this.isShow_VerifyPssPopup = true;
    },
    hadleHideVerifyPssPopup() {
      this.isShow_VerifyPssPopup = false;
    },

    getPayPass(pass) {
      this.isShow_VerifyPssPopup = false;
      this.payPass = pass;
      let data = {
        password: pass,
        hasThrow: true,
      };
      // 用接口判断输入密码是否正确
      this.$post(this.URL.user.verify, data).then((res) => {
        if (res.code == 0) {
          if (true == res.data.verify) {
            this.common.updateVerifyStatus(true);
            this.isShowAsset = !this.isShowAsset;
            this.getdata();
            this.$store.dispatch("SetWelfareEyes_2", this.isShowAsset);
            this.$toast(res.message);
          } else {
            //this.$toast("密码输入错误");
            // this.$toast(this.$t('toast.passwd_error'));
            this.$toast(res.message);
          }
        } else {
          this.$toast(res.message);
        }
      });
    },

    // 路由跳转
    goRrouter(data) {
      if (data.path) {
        if (data.apiurl != undefined) {
          let querys = {
            apiurl: data.apiurl,
            title: data.text,
            integralSummary: data.integralSummary,
            params: { ...data.params },
            ...data.params,
          };
          this.$router.push({
            path: data.path,
            query: querys,
          });
        } else {
          this.$router.push(data.path);
        }
      }
    },

    preserve() {
      this.$router.push({
        path: "/income/list",
        query: {
          id: "101",
          name: this.$tc("income.doc35", 2),
        },
      });
    },
    link(item) {
      if(item.id == 5) {
        return
      }

      if (this.common.isVerify()) {
        if (item.id == "100") {
          this.$router.push({
            path: "/income/team",
          });
        } else {
          this.$router.push({
            path: "/income/list",
            query: {
              id: item.id,
            },
          });
        }
      } else {
         this.isShow_VerifyPssPopup = true;
      }
    },
    status() {
      this.is_a = !this.is_a;
    },
  },
};
</script>


<style lang="less" scoped>
#app {
  .container {
    padding: 0 0.2rem 0.4rem 0.2rem;
  }
  .head {
    background: #0755cd;
    border-radius: .16rem;
    color: #fff;
    padding: 0.3rem 0.3rem 0.24rem 0.3rem;
    margin-bottom: 0.2rem;
    .cname {
      font-size: 0.26rem;
      opacity: 0.7;
    }
    .str {
      img {
        height: 0.34rem;
      }
    }
    .price {
      padding: 0.3rem 0;
      font-size: 0.7rem;
      font-weight: 500;
      color: #ffffff;
      span {
        font-size: 0.32rem;
        margin-left: 0.1rem;
      }
      var {
        font-size: 0.4rem;
        margin-right: 0.1rem;
      }
    }
    .status {
      img {
        height: 0.3rem;
      }
    }
    ul {
      border-top: 0.01rem solid rgba(255, 255, 255, 0.2);
      padding: 0.3rem 0;
      li {
        padding: 0.06rem 0;
        .name {
          opacity: 0.6;
        }
      }
    }
  }
  .box1 {
    background: #ffffff;
    border-radius: 0.16rem;
    box-shadow: 0px 0.1rem 0.14rem 0px rgba(0, 0, 0, 0.03);
    padding: 0 0.3rem;
    .cname {
      font-size: 0.26rem;
      font-weight: 600;
      color: #222222;
      img {
        margin-right: 0.12rem;
        height: 0.38rem;
      }
    }
    ul {
      li {
        padding: 0.3rem 0;
        border-bottom: 0.01rem solid #ececec;
        &:last-child {
          border: 0;
        }
        span {
          font-size: 0.22rem;
          margin-top: 0.1rem;
          display: block;
        }
        .flex {
          padding-right: 0.2rem;
          line-height: 0.28rem;
        }
        .str {
          font-size: 0.3rem;
        }
      }
    }
  }
}
</style>
